package dd.control;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import xml.Message;
import dd.model.Event;
import dd.model.Model;
import dd.view.CreateForm;
import dd.view.addChoiceScreen;
import dd.view.addEdgeFrame;

public class modCreateResponseController {
	/**
	 * call when the moderator get a create response save the event id in the response go to different screen for open
	 * and close mode
	 */
	CreateForm cf;

	public modCreateResponseController() {
		Model model = Model.getInstance();
		cf = model.getCreateForm();
	}

	public void process(Message response) {
		Model model = Model.getInstance();
		Event e = model.getEvent();
		Node update = response.contents.getFirstChild();
		NamedNodeMap map = update.getAttributes();
		String eventid = map.getNamedItem("id").getNodeValue();
		e.setEventID(eventid);
		if (e.getMode().equals("open")) {// if open mode
			addChoiceScreen addchoiceScreen = new addChoiceScreen(e);
			// addchoiceScreen.getLBlModeratorChoice().setVisible(false);
			addchoiceScreen.setVisible(true);
			model.getCreateForm().dispose();
		} else if (e.getMode().equals("closed")) { // if close mode
			addEdgeFrame aes = new addEdgeFrame();
			aes.setVisible(true);
			model.getmac().dispose();
		} else {

		}

	}
}
